﻿namespace WMS6.Web.Analytics
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class Invoice2RptQuery : BasePage
    {
        protected Button btnSearch;
        protected DropDownList ddlBillingObject;
        protected DropDownList ddlBillingObjectIDOper;
        protected DropDownList ddlBillingObjectOper;
        protected DropDownList ddlDueFromTo;
        protected DropDownList ddlDueFromToOper;
        protected HtmlForm F15660;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlHead Head1;
        protected HtmlImage img1;
        protected Label lblBillingObject;
        protected Label lblBillingObjectID;
        protected Label lblDueFromTo;
        protected Label lblEndDate;
        protected Label lblMsg;
        protected Label lblQuery;
        protected HtmlLink mycss;
        protected TextBox txtBillingObject;
        protected TextBox txtEndDate;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("Invoice2RptList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
            {
                this.lblMsg.Text = "请输入查询日期！";
            }
            else
            {
                DateTime dt = new DateTime();
                if (!DateTime.TryParse(this.txtEndDate.Text.Trim(), out dt))
                {
                    this.lblMsg.Text = "请输入正确日期！";
                }
                else
                {
                    base.Server.Transfer(string.Format("Invoice2RptList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
                }
            }
        }

        private void LoadData()
        {
            base.InitQueryDDL(this.ddlBillingObjectOper, 0);
            base.InitQueryDDL(this.ddlBillingObjectIDOper, 0);
            base.InitQueryDDL(this.ddlDueFromToOper, 0);
            base.BindData2DDLBySysCode(this.ddlDueFromTo, "DueFromTo");
            base.BindData2DDLBySysCode(this.ddlBillingObject, "BillingObject");
            this.ddlBillingObject.Items.Insert(0, "");
            this.txtEndDate.Text = DateTime.Now.AddDays(-1.0).ToString("yyyy-MM-dd");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
            }
        }

        public string BillingObject
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlBillingObject.SelectedValue))
                {
                    return base.GetParamsString(this.ddlBillingObject.SelectedValue, this.ddlBillingObjectOper.SelectedValue);
                }
                return "";
            }
        }

        public string BillingObjectID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtBillingObject.Text.Trim()))
                {
                    return base.GetParamsString(this.txtBillingObject.Text.Trim(), this.ddlBillingObjectIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string DueFromTo
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlDueFromTo.SelectedValue))
                {
                    return base.GetParamsString(this.ddlDueFromTo.SelectedValue, this.ddlDueFromToOper.SelectedValue);
                }
                return "";
            }
        }

        public string EndDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
                {
                    return Convert.ToDateTime(this.txtEndDate.Text).ToString("yyyy-MM-dd");
                }
                return "";
            }
        }
    }
}

